#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include<cstdlib>
using namespace std;

class Solution
{
private:
public:
    bool CompareMap(std::map<char, int> &mapSrc, std::map<char, int> &mapDst)
    {
        if (mapSrc.size() != mapDst.size())
        {
            return false;
        }

        std::map<char, int>::iterator it = mapSrc.begin();
        while (it != mapSrc.end())
        {
            std::map<char, int>::iterator itDst = mapDst.find(it->first);
            if (itDst != mapDst.end())
            {
                if (itDst->second != it->second)
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
            it++;
        }
        return true;
    }

    bool isAnagram(string s, string t)
    {

        if (s.size() != t.size())
        {
            return false;
        }
        map<char, int> sm, tm;
        // 保存到字典中
        for (int i = 0; i < s.size(); i++)
        {
            if (sm.find(s[i]) == sm.end())
            {
                sm.insert(pair<char, int>(s[i], 1));
            }
            else
            {
                sm[s[i]] += 1;
            }
            if (tm.find(t[i]) == tm.end())
            {
                tm.insert(pair<char, int>(t[i], 1));
            }
            else
            {
                tm[t[i]] += 1;
            }
        }
        // 判断字典是否相同
        return CompareMap(sm,tm);
    }

    bool Hash(string s, string t){
        // sort(s.begin(),s.end());
        // sort(t.begin(),t.end());
        // return s==t;
        if(s.size()!=t.size()){
            return false;
        }
        
        int sa[26];
        int ta[26];
        memset(sa,0,sizeof(sa));
        memset(ta,0,sizeof(ta));

        for(int i=0;i<s.size();i++){
            sa[s[i]-'a'] += 1;
            ta[t[i]-'a'] += 1;
        }

        for(int i=0;i<26;i++){
            if(sa[i]!=ta[i]){
                return false;
            }
        }
        return true;
    }
};

int main()
{
    Solution solu = Solution();
    vector<string> input = {"eat", "tea", "tan", "ate", "nat", "bat"};
    return 0;
}